<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			// 将其他的数据类型转换为Boolean 使用Boolean()函数
			// 数字 ---> 布尔 除了0和NaN 其余都是true
			// 字符串 ---> 布尔 除了空串 其余都是true
			// null和undefined都会转换为false
			// 对象也会转换为true
			
			var a = 123;
			
			// 调用Boolean()函数来将a转换为布尔值
			a = Boolean(a);			
			console.log(typeof a);
			console.log(a);//true
			
			var a = -123;
			a = Boolean(a);			
			console.log(typeof a);
			console.log(a);//true
			
			var a = 0;
			a = Boolean(a);			
			console.log(typeof a);
			console.log(a);//false
			
			var a = Infinity;
			a = Boolean(a);			
			console.log(typeof a);
			console.log(a);//true
			
			var a = NaN;
			a = Boolean(a);			
			console.log(typeof a);
			console.log(a);//false
			
			var a = "hello";
			a = Boolean(a);			
			console.log(typeof a);
			console.log(a);//true
			
			var a = "false";
			a = Boolean(a);			
			console.log(typeof a);
			console.log(a);//true
			
			var a = "";
			a = Boolean(a);			
			console.log(typeof a);
			console.log(a);//false
			
			var a = " ";
			a = Boolean(a);			
			console.log(typeof a);
			console.log(a);//true
			
			var a = null;
			a = Boolean(a);			
			console.log(typeof a);
			console.log(a);//false
			
			var a = undefined;
			a = Boolean(a);			
			console.log(typeof a);
			console.log(a);//false
		</script>
	</head>
	<body>
	</body>
</html>
